package com.alan.cueencoding.util;

import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author Alan.Xiao
 * @date 2022/10/4
 */
@Data
public class Result<T> implements Serializable {
    private Integer status = 200;

    private String msg;

    private T data;

    private LocalDateTime timestamp = LocalDateTime.now();


    public static Result success(Object data) {
        return new Result(data, null, 200);
    }

    public static Result fail(String msg) {
        return new Result(null, msg, 500);
    }

    public Result(T data, String msg, Integer status) {
        this.data = data;
        this.msg = msg;
        this.status = status;
    }
}
